#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'tian'
__data__ = '2021/10/21 15:28'
# software: PyCharm

from django import forms
from apps.web import models
from apps.web.forms.bootstrap import  BootStrapForm


class WikiModelForm(BootStrapForm,forms.ModelForm):

    class Meta:
        model = models.Wiki
        exclude = ["project","depth"]

    def __init__(self,request,*args,**kwargs):
        super().__init__(*args,**kwargs)
        table_data_list = [("","请选择"),]
        data_list = models.Wiki.objects.filter(project=request.tracer.project).values_list("pk","title")
        table_data_list.extend(data_list)
        self.fields['parent'].choices = table_data_list
